package main

// Channels are the pipes that connect concurrent goroutines.
// You can send values into channels from one goroutine and receive
// those values into another goroutine.

// By default sends and receives block until both the sender and receiver are ready.

import "fmt"

func main() {
	// create a new channel with make(chan val-type)
	// Channels are typed by the values they convey.
	messages := make(chan string)

	// send a value into a channel using the channel <- syntax.
	// Here we send "ping" to the messages channel we made above, from
	// a new goroutine.
	go func() {
		messages <- "ping"
	}()

	// The <- channel syntax receives a value from the channel.
	msg := <-messages
	fmt.Println(msg)
}
